package cn.tedu.hotelApi.dict.conrtoller;

import cn.tedu.hotelApi.base.response.JsonResult;
import cn.tedu.hotelApi.dict.pojo.dto.DictParam;
import cn.tedu.hotelApi.dict.pojo.dto.DictQuery;
import cn.tedu.hotelApi.dict.pojo.vo.DictVO;
import cn.tedu.hotelApi.dict.service.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/v1/dict")
public class DictController {
    @Autowired
    private DictService dictService;
    @GetMapping("dictSelect")
    public JsonResult dictSelect(DictQuery dictQuery){
        List<DictVO> dictVO = dictService.dictSelect(dictQuery);
        return JsonResult.ok(dictVO);
    }
    @PostMapping("dictSave")
    public JsonResult dictSave(DictParam dictParam){
        dictService.dictSave(dictParam);
        return JsonResult.ok();
    }
    @PostMapping("dictDelect/{id}")
    public JsonResult dictDelect(@PathVariable Long id){
        dictService.dictDelect(id);
        return JsonResult.ok();
    }
}
